export const showToast = (title, options = {}) => {
  uni.showToast({
    title,
    icon: 'none',
    duration: options.duration || 1500
  })
}
//上一页
export const prePage = (page=2)=>{
	let pages = getCurrentPages();
	let prePage = pages[pages.length - page];
	return prePage.$vm;
}
export const getNavbarHeight = () => {
  // 状态栏高度
  return new Promise((resolve,reject)=>{
    let statusHeight, allHeight, titleHeight,menuRight,menuHeight
    uni.getSystemInfo({
        success:(res)=>{
          statusHeight = res.statusBarHeight
          const { top, height,width } = uni.getMenuButtonBoundingClientRect()
          const mt = top - statusHeight
          titleHeight = mt + height
          allHeight = statusHeight + titleHeight
          menuRight = res.screenWidth - width - 7
          menuHeight = height
          resolve({ statusHeight, allHeight, titleHeight,menuRight,menuHeight })
        }
    })
  })
}
export default (Vue) => {
  Vue.prototype.$showToast = showToast
  Vue.prototype.$prePage = prePage
  Vue.prototype.$getNavbarHeight = getNavbarHeight
};


